package demo1;

class Animal {//父类
    public String name;
    public int age;
    static {
        System.out.println("Animal::static::{}");//静态只执行一次
    }
    {
        System.out.println("Animal::{}");//实例
    }
//    public Animal() {
//
//    }
    public Animal(String name, int age) {//父类的构造方法
        this.name = name;
        this.age = age;
        System.out.println("Animal(String name, int age)......");
    }
    public void eat() {//父类的成员方法
        System.out.println(name + "正在吃饭...");
    }
}


class Dog extends Animal {//子类
    static {
        System.out.println("Dog::static::{}");
    }
    {
        System.out.println("Dog::{}");//实例
    }
//    public Dog() {
//        super();
//    }
    public Dog(String name, int age) {//子类的构造方法，先调用父类的构造方法
        super(name, age);//super();必须在构造方法的第一行
        System.out.println("Dog(String name, int age)......");
    }
    public void bark() {//子类的成员方法
        System.out.println(name + "正在汪汪叫...");
    }
}

class Bird extends Animal {//子类
    static {
        System.out.println("Bird::static::{}");
    }
    {
        System.out.println("Bird::{}");//实例
    }
    public Bird(String name, int age) {//子类的构造方法
        super(name, age);
        System.out.println("Bird(String name, int age)......");
    }
//    public Bird() {
//        super("小云", 2);//重点在这里
//    }
    public void fly() {//子类的成员方法
        System.out.println(name + "正在飞...");
    }
}

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog("旺财", 1);//实例化Dog对象
        //Bird bird = new Bird("小云", 2);
        System.out.println("==============================");
        Dog dog2 = new Dog("旺财", 1);
    }
}
